home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trading on the Edge
/
Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin
/
pc
/
mac_file
/
vendor_d
/
neuralwa
/
nw2v50
/
lvq.ind
< prev
next >
Wrap
File List
|
1993-08-23
|
5KB
|
278 lines
inst4.1
!*********************************************************************
!* *
!* Linear Vector Quantization (LVQ) Network Builder *
!* *
!*********************************************************************
!
! *** check that input / output PE count is non-zero
?&In 1
>bge InOK
@Err "LVQ MUST have at least 1 input PE"
:InOK
?&Out 2
>bge OutOK
@Err "LVQ MUST have at least 2 output categories"
:OutOK
?&Prt &Out
>bge Hid1OK
=&Prt &Out
:Hid1OK
! Round up # protoypes for equidistribution
! Store #prototypes per class in n7
=n7 &Prt
+n7 &Out
-n7 1
/n7 &Out
=&Prt n7
*&Prt &Out
@LdCS "lvq" !control strategy
! Build the LR schedule
! Use 3 cols for LVQ1, 2 for LVQ2
@NLRS "lvq"
! First set up schedule transition points
! LVQ1
?Q1LC 10
>bgt Q1LCOK
=Q1LC 10 !Force some LVQ1
:Q1LCOK
=n0 Q1LC !Total # iterations for LVQ1
/n0 3 !Transition count
=lcta n0
=lctb n0
*lctb 2
=lctc Q1LC
! LVQ2
=n0 Q2LC !Total # iterations for LVQ2
?n0 0
>ble NoLVQ2
/n0 2 !Transition count
=lctd lctc
+lctd n0
=lcte lctc
+lcte Q2LC
=LrnN lcte !Total learn count
>br LRSParms
:NoLVQ2
=lctd 0
=lcte 0
=LrnN lctc !Total learn count
:LRSParms
! Parameter names
=ArrX 1
=lcft "Attraction Rt1"
=ArrX 2
=lcft "Attraction Rt2"
=ArrX 3
=lcft "Repulsion Rate"
=ArrX 4
=lcft "Conscience"
=ArrX 5
=lcft "Frequency Est."
=rcft "Parzen Spread"
=ArrX 6
=lcft "LVQ2 Width"
! Attraction Rate 1
=ArrX 1
=lcfa Q1LR
=lcfb lcfa
/lcfb 2
=lcfc lcfb
/lcfc 2
=lcfd Q2LR
=lcfe lcfd
/lcfe 2
! Attraction Rate 2 (unused for LVQ2)
=ArrX 2
=lcfa 0.0
=lcfb 0.0
=lcfc 0.0
=lcfd 0.0
=lcfe 0.0
?Q1IC 0 ! In-class winner learns?
>beq RepulRt ! If no, then don't set
=lcfa Q1LR
=lcfb lcfa
/lcfb 2
=lcfc lcfb
/lcfc 2
:RepulRt
! Repulsion Rate (unused for LVQ2)
=ArrX 3
=lcfa Q1LR
=lcfb lcfa
/lcfb 2
=lcfc lcfb
/lcfc 2
=lcfd 0.0
=lcfe 0.0
! Conscience
=ArrX 4
=lcfa Q1CF
=lcfb lcfa
/lcfb 2
=lcfc lcfb
/lcfc 2
=lcfd 0.0
=lcfe 0.0
! Frequency Estimation (unused for LVQ2)
=ArrX 5
=lcfa Q1FE
=lcfb lcfa
/lcfb 2
=lcfc lcfb
/lcfc 2
=lcfd 0.0
=lcfe 0.0
=rcfa 0.0 !Parzen WIndow
! Width Parameter (LVQ2 only)
=ArrX 6
=lcfa 0.0
=lcfb 0.0
=lcfc 0.0
=lcfd Q2WP
=lcfe lcfd
*lcfe 2
@SLRS
=ArrX 0
=netn "untitled"
=DLnF 0 !learn re-display off
=DRcF 0 !recall re-display off
! *** Build the Input Layer ***
@LLdf !load default layer to mi_layer structure
=LDln "In" !layer name
=Lpes &In !copy # of input PEs from menu
=x 100 !place to put layer on screen
=y 80
=n3 5 !PE Spacing
*n3 n7
*n3 &Out
/n3 &In
?n3 1
>bge n3OK
=n3 1
:n3OK
=LDsp n3
#Incl "stdnwgtf.iif" !standard # weight fields
@LAdd !add the input layer
! *** Build the Kohonen Layer ***
@LLdf !start with default layer again
=LDln "Kohonen" !Kohonen layer
=Lsum "lvq" !Summation Function
=Lcmp "lvq" !Output Function
=Llrn "lvq" !Learn Function
=Lpes &Prt !Number of PE's
=LInL -1.0 !Should be same as input low value
=LInH 1.0 !Should be same as input high value
+y 100 !up higher on display
=LDsp 5 !PE Spacing
@LDfW !Default # weight fields
@LAdd
! *** Connect Input Layer to the Kohonen layer ***
=SPEl 1 !Destination = Kohonen Layer
@SlPE
@NrPE
=cnwt 0.0 !connection weight = 0.0
=cnty WVar !fixed
=cnsc WRel !Relative
=NPEl 0 !Source = Input Layer
@NrPE
@LCFl !fully connect to input layer
! *** Build the output layer ***
=x 100
@LLdf !load default layer to mi_layer structure
=LDln "Out" !layer name
=Lpes &Out !copy # of input PEs from menu
=Lsum "sum" !Standard Summation Function
=Ltrn "linear" !Transfer Function
=Lcmp "direct" !Output Function
+y 100 !up higher on display
=LDsp 5 !PE Spacing
*LDsp n7
#Incl "stdnwgtf.iif" !standard # weight fields
@LAdd !add the output layer
! *** Connect Kohonen Layer to Output Layer ***
=cnwt 1.0 !connection weight = 1.0
=cnty WFix !fixed
=SPEl 2 !Destination = Output Layer
=SPEn 0 !Output Layer PE index
=NPEl 1 !Source = Kohonen Layer
=NPEn 0 !Kohonen Layer PE index
:L1
=n1 0 !n7 count
:L2
@SlPE !select next PE in output layer
@NrPE !select next PE in Kohonen layer
@PCon !Connect Kohonen PE to output PE
+n1 1 !increment n7 count
+NPEn 1 !increment Kohonen Layer PE index
?n1 n7 !check for loop end
>blt L2
+SPEn 1 !increment output Layer PE count
?SPEn &Out
>blt L1
! *** Select Control Strategy & L/R Schedule ***
@LLsl !load super layer
=LDnd 3 !Force network display
=Lctl "lvq" !control strategy
=Llrs "lvq" !L/R Schedule
#Incl "stdioset.iif" !standard I/O settings
=Lscl -1.0 !input low-value
=Loff 1.0 !input high-value
=Llow 0. !output low-value
=Lhgh 1. !output high-value
=Lax1 Epch !epoch size
=Lax2 0 !Aux 2 used for optimized learning
@SVsl !save the super layer back
!
=Grph 1
=GrLF "lvq" !instrument list file
!
! Recall/Test modes
=RnTm 1
=RnRm 1
!set to learn until
=RnLm 4
!
=jogl -1.0 !lower limit for jog
=jogh +1.0 !upper limit for jog
=seed 257 !starting seed number
@seed !set the seed
@Nini !Initialize the network
@EOF